package com.mz.mattress.admin.api.merchant;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mz.mattress.admin.api.req.MemberBalanceRecordQueryReq;
import com.mz.mattress.admin.common.Holder;
import com.mz.mattress.admin.service.MemberBalanceRecordService;
import com.mz.mattress.api.common.Constants;
import com.mz.mattress.api.common.Result;
import com.mz.mattress.api.entity.MemberBalanceRecord;
import com.mz.mattress.api.jwt.MerchantJwt;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping(Constants.MERCHANT_PATH + "memberBalanceRecord")
public class MemberBalanceRecordController {

    @Autowired
    private MemberBalanceRecordService memberBalanceRecordService;

    @GetMapping("/listPage")
    public Result<IPage<MemberBalanceRecord>> listPage(MemberBalanceRecordQueryReq req) {
        MerchantJwt userJwt = Holder.MERCHANT_JWT_THREAD_LOCAL.get();
        log.info("memberMerId={}", userJwt.getMemberMerId());
        req.setMemberId(userJwt.getMemberMerId());
        return memberBalanceRecordService.listPage(req);
    }

}
